home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / Kubuntu 8.10 / kubuntu-8.10-desktop-i386.iso / casper / filesystem.squashfs / usr / include / malloc.h < prev    next >
C/C++ Source or Header  |  2008-09-29  |  6KB  |  175 lines

  1. /* Prototypes and definition for malloc implementation.
  2.    Copyright (C) 1996, 1997, 1999, 2000, 2002-2004, 2005, 2007
  3.    Free Software Foundation, Inc.
  4.    This file is part of the GNU C Library.
  5.  
  6.    The GNU C Library is free software; you can redistribute it and/or
  7.    modify it under the terms of the GNU Lesser General Public
  8.    License as published by the Free Software Foundation; either
  9.    version 2.1 of the License, or (at your option) any later version.
  10.  
  11.    The GNU C Library is distributed in the hope that it will be useful,
  12.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  13.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  14.    Lesser General Public License for more details.
  15.  
  16.    You should have received a copy of the GNU Lesser General Public
  17.    License along with the GNU C Library; if not, write to the Free
  18.    Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
  19.    02111-1307 USA.  */
  20.  
  21. #ifndef _MALLOC_H
  22. #define _MALLOC_H 1
  23.  
  24. #include <features.h>
  25. #include <stddef.h>
  26. # define __malloc_ptr_t  void *
  27.  
  28. /* Used by GNU libc internals. */
  29. #define __malloc_size_t size_t
  30. #define __malloc_ptrdiff_t ptrdiff_t
  31.  
  32. #ifdef __GNUC__
  33.  
  34. # define __MALLOC_P(args)    args __THROW
  35. /* This macro will be used for functions which might take C++ callback
  36.    functions.  */
  37. # define __MALLOC_PMT(args)    args
  38.  
  39. #else    /* Not GCC.  */
  40.  
  41. # define __MALLOC_P(args)    args
  42. # define __MALLOC_PMT(args)    args
  43.  
  44. #endif    /* GCC.  */
  45.  
  46.  
  47. __BEGIN_DECLS
  48.  
  49. /* Allocate SIZE bytes of memory.  */
  50. extern void *malloc __MALLOC_P ((size_t __size)) __attribute_malloc__ __wur;
  51.  
  52. /* Allocate NMEMB elements of SIZE bytes each, all initialized to 0.  */
  53. extern void *calloc __MALLOC_P ((size_t __nmemb, size_t __size))
  54.        __attribute_malloc__ __wur;
  55.  
  56. /* Re-allocate the previously allocated block in __ptr, making the new
  57.    block SIZE bytes long.  */
  58. /* __attribute_malloc__ is not used, because if realloc returns
  59.    the same pointer that was passed to it, aliasing needs to be allowed
  60.    between objects pointed by the old and new pointers.  */
  61. extern void *realloc __MALLOC_P ((void *__ptr, size_t __size))
  62.        __attribute_warn_unused_result__;
  63.  
  64. /* Free a block allocated by `malloc', `realloc' or `calloc'.  */
  65. extern void free __MALLOC_P ((void *__ptr));
  66.  
  67. /* Free a block allocated by `calloc'. */
  68. extern void cfree __MALLOC_P ((void *__ptr));
  69.  
  70. /* Allocate SIZE bytes allocated to ALIGNMENT bytes.  */
  71. extern void *memalign __MALLOC_P ((size_t __alignment, size_t __size))
  72.        __attribute_malloc__ __wur;
  73.  
  74. /* Allocate SIZE bytes on a page boundary.  */
  75. extern void *valloc __MALLOC_P ((size_t __size))
  76.        __attribute_malloc__ __wur;
  77.  
  78. /* Equivalent to valloc(minimum-page-that-holds(n)), that is, round up
  79.    __size to nearest pagesize. */
  80. extern void * pvalloc __MALLOC_P ((size_t __size))
  81.        __attribute_malloc__ __wur;
  82.  
  83. /* Underlying allocation function; successive calls should return
  84.    contiguous pieces of memory.  */
  85. extern void *(*__morecore) __MALLOC_PMT ((ptrdiff_t __size));
  86.  
  87. /* Default value of `__morecore'.  */
  88. extern void *__default_morecore __MALLOC_P ((ptrdiff_t __size))
  89.        __attribute_malloc__;
  90.  
  91. /* SVID2/XPG mallinfo structure */
  92.  
  93. struct mallinfo {
  94.   int arena;    /* non-mmapped space allocated from system */
  95.   int ordblks;  /* number of free chunks */
  96.   int smblks;   /* number of fastbin blocks */
  97.   int hblks;    /* number of mmapped regions */
  98.   int hblkhd;   /* space in mmapped regions */
  99.   int usmblks;  /* maximum total allocated space */
  100.   int fsmblks;  /* space available in freed fastbin blocks */
  101.   int uordblks; /* total allocated space */
  102.   int fordblks; /* total free space */
  103.   int keepcost; /* top-most, releasable (via malloc_trim) space */
  104. };
  105.  
  106. /* Returns a copy of the updated current mallinfo. */
  107. extern struct mallinfo mallinfo __MALLOC_P ((void));
  108.  
  109. /* SVID2/XPG mallopt options */
  110. #ifndef M_MXFAST
  111. # define M_MXFAST  1    /* maximum request size for "fastbins" */
  112. #endif
  113. #ifndef M_NLBLKS
  114. # define M_NLBLKS  2    /* UNUSED in this malloc */
  115. #endif
  116. #ifndef M_GRAIN
  117. # define M_GRAIN   3    /* UNUSED in this malloc */
  118. #endif
  119. #ifndef M_KEEP
  120. # define M_KEEP    4    /* UNUSED in this malloc */
  121. #endif
  122.  
  123. /* mallopt options that actually do something */
  124. #define M_TRIM_THRESHOLD    -1
  125. #define M_TOP_PAD           -2
  126. #define M_MMAP_THRESHOLD    -3
  127. #define M_MMAP_MAX          -4
  128. #define M_CHECK_ACTION      -5
  129. #define M_PERTURB        -6
  130.  
  131. /* General SVID/XPG interface to tunable parameters. */
  132. extern int mallopt __MALLOC_P ((int __param, int __val));
  133.  
  134. /* Release all but __pad bytes of freed top-most memory back to the
  135.    system. Return 1 if successful, else 0. */
  136. extern int malloc_trim __MALLOC_P ((size_t __pad));
  137.  
  138. /* Report the number of usable allocated bytes associated with allocated
  139.    chunk __ptr. */
  140. extern size_t malloc_usable_size __MALLOC_P ((void *__ptr));
  141.  
  142. /* Prints brief summary statistics on stderr. */
  143. extern void malloc_stats __MALLOC_P ((void));
  144.  
  145. /* Record the state of all malloc variables in an opaque data structure. */
  146. extern void *malloc_get_state __MALLOC_P ((void));
  147.  
  148. /* Restore the state of all malloc variables from data obtained with
  149.    malloc_get_state(). */
  150. extern int malloc_set_state __MALLOC_P ((void *__ptr));
  151.  
  152. /* Called once when malloc is initialized; redefining this variable in
  153.    the application provides the preferred way to set up the hook
  154.    pointers. */
  155. extern void (*__malloc_initialize_hook) __MALLOC_PMT ((void));
  156. /* Hooks for debugging and user-defined versions. */
  157. extern void (*__free_hook) __MALLOC_PMT ((void *__ptr,
  158.                     __const __malloc_ptr_t));
  159. extern void *(*__malloc_hook) __MALLOC_PMT ((size_t __size,
  160.                          __const __malloc_ptr_t));
  161. extern void *(*__realloc_hook) __MALLOC_PMT ((void *__ptr, size_t __size,
  162.                           __const __malloc_ptr_t));
  163. extern void *(*__memalign_hook) __MALLOC_PMT ((size_t __alignment,
  164.                            size_t __size,
  165.                            __const __malloc_ptr_t));
  166. extern void (*__after_morecore_hook) __MALLOC_PMT ((void));
  167.  
  168. /* Activate a standard set of debugging hooks. */
  169. extern void __malloc_check_init __MALLOC_P ((void));
  170.  
  171.  
  172. __END_DECLS
  173.  
  174. #endif /* malloc.h */
  175.